import type { AxiosRequestConfig } from 'axios';

export type RequestKey = string;
/**
 * 获取请求的key
 */
export function getRequestKey(config: AxiosRequestConfig): RequestKey {
  const { url, method, data, params } = config;
  const arr = [
    url ?? '',
    method ?? '',
    typeof data === 'string' ? data : JSON.stringify(data),
    typeof params === 'string' ? params : JSON.stringify(params),
  ];
  return arr.join('');
}
